package com.example.doctor.utils;

import cn.hutool.core.lang.copier.Copier;
import com.example.common.entity.DoctorBaseInfo;
import com.example.common.utils.IdUtils;
import com.example.doctor.jpa.DoctorBaseInfoRepository;
import com.tencentcloudapi.aa.v20200224.AaClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;

@Slf4j
@Component
public class UserUtils {

    @Resource
    private HttpServletRequest request;

    @Resource
    private DoctorBaseInfoRepository doctorBaseInfoRepository;

    /**
     * 获取当前登录用户信息
     *
     * @return 用户信息
     */
    public DoctorBaseInfo getUser() {
        String id = request.getHeader("UID");
        Long dcId = Long.valueOf(id).longValue();
        DoctorBaseInfo baseInfo =  doctorBaseInfoRepository.findByDcId(dcId);
        return baseInfo;
    }

    public static void main(String[] args) {
        BigDecimal count = BigDecimal.valueOf(10l);
        BigDecimal newCount = BigDecimal.valueOf(2.2);
        System.out.println(count.divide(newCount,2,BigDecimal.ROUND_CEILING));
        BigDecimal b = BigDecimal.TEN;
        System.out.println(b);
    }
}
